﻿namespace AddressBook.Web.Reports
{
  #region "Using Statements"
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;

  using Business.Contact;
  using Business.Event;
  using Business.Person;
  #endregion

  public class MailingLabelData
  {
    public static  IEnumerable<MailingLabel> GetMailingLabels(String eventId)
    {
      Event eventData = Event.GetEvent(int.Parse(eventId));
      List<MailingLabel> labels = new List<MailingLabel>();
      StateProvinceList states = StateProvinceList.GetStateProvinceList();

      foreach (Guest guest in eventData.Guests)
      {
        if (guest.Address != null)
        {
          StateProvinceInfo info = states.FirstOrDefault(s => s.Id == guest.Address.StateProvinceId);

          labels.Add(new MailingLabel(guest.Name,
                                      guest.Address.Address1,
                                      guest.Address.Address2,
                                      guest.Address.City, 
																			info.StateProvinceCode, 
																			guest.Address.PostalCode));
        }
      }

      return labels;
    }
  }
}